package com.yuting.practice.sort;

import java.util.Arrays;

public class Bubble {


    public static void bubble(int[] arr){
        for (int i = 0; i < arr.length - 1; i++) {
            boolean sorted = true;
            for(int j = 0; j < arr.length - 1 - i; j++){

                if(arr[j] > arr[j + 1]){
                    sorted = true;

                    int tmp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = tmp;
                }


            }
        }
    }

    public static void main(String[] args) {
        int[] a = {1,3,4,2,9,7};

        bubble(a);

        for(int i : a){
            System.out.println(i);
        }
    }
}
